package cn.ihelloworld.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.ihelloworld.bean.Article;
import cn.ihelloworld.bean.PageResult;
import cn.ihelloworld.dao.IArticleDao;
import cn.ihelloworld.dao.Pagation;
import cn.ihelloworld.service.IArticleService;
@Service
@Transactional
public class ArticleServiceImpl implements IArticleService {

	@Autowired
	private IArticleDao articleDao;
	
	@Override
	public Article get(String id) {
		// TODO Auto-generated method stub
		return articleDao.get(id);
	}

	@Override
	public List<Article> select(Article t) {
		// TODO Auto-generated method stub
		return articleDao.select(t);
	}

	@Override
	public Pagation<Article> selectForPage(Article t, int currentPage,
			int pageSize) {
		// TODO Auto-generated method stub
		return articleDao.selectForPage(t, currentPage, pageSize);
	}

	@Override
	public void saveOrUpdate(Article t) {
		// TODO Auto-generated method stub
		articleDao.saveOrUpdate(t);
	}

	@Override
	public void delete(String id) {
		// TODO Auto-generated method stub
		articleDao.delete(id);
	}

	@Override
	public void delete(String[] ids) {
		// TODO Auto-generated method stub
		articleDao.delete(ids);
	}

	@Override
	public List<Article> selectLast(String catagoryId,int num) {
		// TODO Auto-generated method stub
		return articleDao.selectLast(catagoryId,num);
	}

	@Override
	public List<Article> selectHot(String catagoryId, int num) {
		// TODO Auto-generated method stub
		return articleDao.selectHot(catagoryId, num);
	}

	@Override
	public List<Article> selectHotByTag(String tag, int num) {
		// TODO Auto-generated method stub
		return articleDao.selectHotByTag(tag, num);
	}

	@Override
	public List<Article> selectLastByTag(String tag, int num) {
		// TODO Auto-generated method stub
		return articleDao.selectLastByTag(tag, num);
	}

	@Override
	public void saveOrUpdate(List<Article> articles) {
		// TODO Auto-generated method stub
		for(Article article:articles){
			articleDao.saveOrUpdate(article);
		}
	}

	@Override
	public void update(List<Article> list) {
		for(Article ar:list){
			System.out.println(ar.getCatagoryId());
		}
		articleDao.update(list);
	}

	@Override
	public List<Article> selectPreNext(String articleId) {
		// TODO Auto-generated method stub
		return articleDao.selectPreNext(articleId);
	}

  @Override
  public PageResult<Article> selectByPage(String catagoryId,int page)
  {
    // TODO Auto-generated method stub
    return articleDao.selectByPage(catagoryId,page);
  }

}
